package com.lovetemperature.action;

import java.util.List;

import com.lovetemperature.model.Member;
import com.lovetemperature.model.Sex;
import com.lovetemperature.service.MemberService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class EditMemberAction extends ActionSupport {
	private MemberService memberService;
	private Member originMember;
	private Sex[] candidateSexes = Sex.values();
	
	private double rechargeNum;
	
	public String showMember() {
		originMember = (Member) ActionContext.getContext().getSession().get("user");
		ActionContext.getContext().put("originMember", originMember);
		ActionContext.getContext().put("candidateSexes", candidateSexes);
		return "success";
	}
	
	public String editMember() {
		if(memberService.update(originMember)){
			return "success";
		}else{
			return "fial";
		}
	}
	
	public String recharge(){
		if(rechargeNum!=0){
			memberService.recharge(originMember, rechargeNum);
		}
		return "success";
	}
	
	public MemberService getMemberService() {
		return memberService;
	}
	public void setMemberService(MemberService memberService) {
		this.memberService = memberService;
	}
	public Member getOriginMember() {
		return originMember;
	}

	public void setOriginMember(Member originMember) {
		this.originMember = originMember;
	}

	public Sex[] getCandidateSexes() {
		return candidateSexes;
	}

	public void setCandidateSexes(Sex[] candidateSexes) {
		this.candidateSexes = candidateSexes;
	}

	public double getRechargeNum() {
		return rechargeNum;
	}

	public void setRechargeNum(double rechargeNum) {
		this.rechargeNum = rechargeNum;
	}
}
